<?php

namespace app\model;

use app\utils\Md5Service;
use \think\facade\Db;
use think\facade\Log;

class OmsOrderModel
{
    public static function lists($param): array
    {
      if (isset($param['order_ids']) && !empty($param['order_ids'])) {
          $where[] = ['order_id', 'IN', $param['order_ids']];
      }

      $param['page'] = ($param['page'] - 1) < 0 ? 1 : $param['page'];

      $lists = Db::table('yoshop_order')->alias('o')
          ->join('xl_networks n', 'n.id = o.network_id', 'left')
          ->where([$where])
          ->field('o.*, n.name as network_name')
          ->order('order_id desc')
          ->limit(($param['page'] - 1) * $param['limit'], $param['limit'])
          ->select()->toArray();

      $count = Db::table('yoshop_order')
          ->where([$where])
          ->count();
          
      return ['lists' => $lists, 'count' => $count];
    }
}